<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>函数传参</title>
	<style type="text/css">
		div{
			background: #000;
			width: 100px;
			height: 100px;
		}
	</style>
	<script type="text/javascript">
		function setColor(color){
			var oDiv=document.getElementById('oDiv');
            oDiv.style.background=color;
		}
	
	</script>
</head>
<body>
    <input type="button" value="红" onclick="setColor('red')">
    <input type="button" value="黄" onclick="setColor('yellow')">
    <input type="button" value="绿" onclick="setColor('green')">
    <div id="oDiv"></div>
</body>
</html>